<template>
 <el-card>
   <el-form :model="loginForm">
     <el-form-item label="账户" prop="username">
       <el-input v-model="loginForm.username" placeholder="请输入账户"></el-input>
     </el-form-item>
     <el-form-item label="密码" prop="password">
       <el-input v-model="loginForm.password" placeholder="请输入密码" type="password"></el-input>
     </el-form-item>
   </el-form>
   <el-button @click.prevent="onLogin">登录</el-button>
 </el-card>
</template>

<script setup>
import {ref} from "vue";
import {useRouter} from 'vue-router'
import {useUserStore} from "@/store/sys/user";

const router = useRouter()
const userStore = useUserStore()

const visiblePassword = ref(false)
const loginForm = ref({
  username: '',
  password: ''
})

const onLogin = async () => {
  await userStore.login(loginForm.value)
  await router.replace({
    name: 'Home'
  })
}
</script>

<style scoped>

</style>
